package cn.ld.module.system.dal.mapper.social;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.system.controller.admin.socail.vo.client.SocialClientPageInVO;
import cn.ld.module.system.dal.entity.social.SocialClientEntity;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SocialClientMapper extends BaseMapperX<SocialClientEntity> {

    default SocialClientEntity selectBySocialTypeAndUserType(Integer socialType, Integer userType) {
        return selectOne(SocialClientEntity::getSocialType, socialType,
                SocialClientEntity::getUserType, userType);
    }

    default PageResult<SocialClientEntity> selectPage(SocialClientPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<SocialClientEntity>()
                .likeIfPresent(SocialClientEntity::getName, inVO.getName())
                .eqIfPresent(SocialClientEntity::getSocialType, inVO.getSocialType())
                .eqIfPresent(SocialClientEntity::getUserType, inVO.getUserType())
                .likeIfPresent(SocialClientEntity::getClientId, inVO.getClientId())
                .eqIfPresent(SocialClientEntity::getStatus, inVO.getStatus())
                .orderByDesc(SocialClientEntity::getId));
    }

}
